package ru.jetsoft.reg112.desktop.data;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class Dictionary {

    private int code;
    private String name;
    private final Map<Integer, String> items;

    public Dictionary(int code, String name) {
        items = new HashMap<>();
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<Integer, String> getItems() {
        return items;
    }

    public Collection<String> getItemTitles() {
        return items.values();
    }

    public String getItemTitle(int id) {
        return items.get(id);
    }

    public void setItems(Map<Integer, String> items) {
        this.items.clear();
        this.items.putAll(items);
    }

    public void addItems(Map<Integer, String> items) {
        this.items.putAll(items);
    }

    public void addItem(int id, String title) {
        this.items.put(id, title);
    }
}
